package in.muton.edushare.url;

import java.util.HashMap;

import org.apache.wicket.markup.html.WebPage;

import com.edushare.common.constants.URLConstants;
import com.edushare.common.vo.Users;


/**
 * 	<p><br/>
 * 	+------------------------+--------------------------------------------------+<br/>
 * 	|		PATTERN			 |				STRATEGY NAME					    |<br/>
 * 	+------------------------+--------------------------------------------------+<br/>
 * 	|	/cheeses?cheese=edam | 	QueryStringUrlEncodingStrategy					|<br/>
 *	|	/cheeses/cheese/edam | 	BookmarkablePageRequestTargetUrlCodingStrategy	|<br/>
 *	|	/cheeses/edam 		 |	IndexedParamUrlCodingStrategy					|<br/>
 * 	|	/cheeses/edam/?age=33|	MixedParamUrlCodingStrategy						|<br/>
 *	|	/cheeses/name/edam 	 |	HybridUrlCodingStrategy							|<br/>
 *	|	/cheeses/edam 		 |	IndexedHybridUrlCodingStrategy					|<br/>
 *	+------------------------+--------------------------------------------------+<br/>
 *</p>
 */

public class URLLoader {
	
	public static final HashMap<String, Class<? extends WebPage>> QueryStringUrlEncodingStrategy = new HashMap<String, Class<? extends WebPage>>();
	//public static final HashMap<String, Class<? extends WebPage>> BookmarkablePageRequestTargetUrlCodingStrategy = new HashMap<String, Class<? extends WebPage>>();
	public static final HashMap<String, Class<? extends WebPage>> IndexedParamUrlCodingStrategy = new HashMap<String, Class<? extends WebPage>>();
	public static final HashMap<String, Class<? extends WebPage>> MixedParamUrlCodingStrategy = new HashMap<String, Class<? extends WebPage>>();
	public static final HashMap<String, Class<? extends WebPage>> HybridUrlCodingStrategy = new HashMap<String, Class<? extends WebPage>>();
	public static final HashMap<String, Class<? extends WebPage>> IndexedHybridUrlCodingStrategy = new HashMap<String, Class<? extends WebPage>>();
	
	
	
		
	static{
		QueryStringUrlEncodingStrategy.put(URLConstants.LOGIN_PATH, in.muton.edushare.pages.EduShareLogin.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.REGISTER_PATH, in.muton.edushare.registration.AdminRegistration.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.VERIFY_PATH, in.muton.edushare.registration.VerifyRegistration.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.TEST_PAGE_PATH, in.muton.edushare.panels.PanelTestPage.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.APP_CONFIG_PATH, in.muton.edushare.appsettings.ConfigApp.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.VERIFY_INVITE_PATH, in.muton.edushare.registration.VerifyEmailInvitePage.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.LOST_PASSWORD,in.muton.edushare.registration.ForgotPassword.class);
		QueryStringUrlEncodingStrategy.put(URLConstants.PASSWORD_RESET, in.muton.edushare.registration.ForgotPasswordKeyVerify.class);
//		QueryStringUrlEncodingStrategy.put(URLConstants.UPLOAD_BACKUPFILES, in.muton.edushare.pages.cp.backup.restore.ConfigUploadProcessPage.class);

		//University private page link
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_PROFILE_PATH, in.muton.edushare.pages.univ.UnivPage.class);
		MixedParamUrlCodingStrategy.put(URLConstants.UNIVERSITY_FILES, in.muton.edushare.pages.univ.UnivFolders.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_CALENDAR, in.muton.edushare.pages.univ.UnivCalendar.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_ACADEMIC_PROGRAMS, in.muton.edushare.pages.univ.UnivAcadProgs.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_BATCHES, in.muton.edushare.pages.univ.UnivBatches.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_PEOPLE, in.muton.edushare.pages.univ.UnivPeople.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_DEPT, in.muton.edushare.pages.univ.UnivDept.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_COURSES, in.muton.edushare.pages.univ.UnivCourses.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_INVITE, in.muton.edushare.pages.univ.UnivInvite.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_NEW_DEPT, in.muton.edushare.pages.univ.DeptCreate.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_NEW_POLL, in.muton.edushare.pages.univ.UnivPoll.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIVERSITY_EDIT, in.muton.edushare.pages.univ.UnivEdit.class);
		
		//Dept private pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_PROFILE_PATH, in.muton.edushare.pages.deptpages.DeptPage.class);
		MixedParamUrlCodingStrategy.put(URLConstants.DEPARTMENT_FILES, in.muton.edushare.pages.deptpages.DeptFolders.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_CALENDAR, in.muton.edushare.pages.deptpages.DeptCalendar.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_UNIVS, in.muton.edushare.pages.deptpages.DeptUniv.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_ACADEMIC_PROGRAM, in.muton.edushare.pages.deptpages.DeptAcadProgs.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_BATCHES, in.muton.edushare.pages.deptpages.DeptBatches.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_PEOPLE, in.muton.edushare.pages.deptpages.DeptPeople.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_COURSES, in.muton.edushare.pages.deptpages.DeptCourses.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_INVITE, in.muton.edushare.pages.deptpages.DeptInvite.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_NEW_COURSE, in.muton.edushare.pages.deptpages.NewCourse.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_NEW_POLL, in.muton.edushare.pages.deptpages.DeptPolls.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_SETTINGS, in.muton.edushare.pages.deptpages.DeptSetting.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPARTMENT_EDIT, in.muton.edushare.pages.deptpages.DeptEdit.class);
		
		//course private pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_PROFILE_PATH, in.muton.edushare.pages.coursepages.CoursePage.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_ASSIGNMENTS, in.muton.edushare.pages.coursepages.CourseAssignmentList.class);
		MixedParamUrlCodingStrategy.put(URLConstants.COURSE_FILES, in.muton.edushare.pages.coursepages.CourseFolder.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_CALENDAR, in.muton.edushare.pages.coursepages.CourseCalendar.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_HISTORY, in.muton.edushare.pages.coursepages.CoursePrevInstances.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_PEOPLE, in.muton.edushare.pages.coursepages.CoursePeople.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_INVITE, in.muton.edushare.pages.coursepages.CourseInvite.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_POLLS, in.muton.edushare.pages.coursepages.CoursePolls.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_DEPT, in.muton.edushare.pages.coursepages.CourseDept.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_UNIV, in.muton.edushare.pages.coursepages.CourseUniv.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_EDIT, in.muton.edushare.pages.coursepages.CourseEdit.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_CREATE_ASSIGNMENT, in.muton.edushare.pages.coursepages.CourseAssignmentCreation.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_GRADING, in.muton.edushare.pages.coursepages.CourseGrading.class);
		
		//User private pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_PROFILE_PATH, in.muton.edushare.pages.user.UserPage.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_ASSIGNMENT, in.muton.edushare.pages.user.UserAssignment.class);
		MixedParamUrlCodingStrategy.put(URLConstants.USER_FILES, in.muton.edushare.pages.user.UserFolders.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_CALENDAR, in.muton.edushare.pages.user.UserCalendar.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_EDIT, in.muton.edushare.pages.user.EditProfilePage.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_POLLS, in.muton.edushare.pages.user.UserPolls.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_UNIV, in.muton.edushare.pages.user.UserUniv.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_DEPARTMENT, in.muton.edushare.pages.user.UserDept.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_COURSES, in.muton.edushare.pages.user.UserCourses.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.USER_SETTINGS, in.muton.edushare.pages.user.UserSettings.class);
		MixedParamUrlCodingStrategy.put(URLConstants.USER_GROUPS, in.muton.edushare.pages.user.CreateGroup.class);
		MixedParamUrlCodingStrategy.put(URLConstants.USER_GRADING, in.muton.edushare.pages.user.UserGrades.class);
		
		//groups private pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_NEWS, in.muton.edushare.pages.group.GroupNews.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_EDIT, in.muton.edushare.pages.group.EditProfile.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_CALENDAR, in.muton.edushare.pages.group.GroupCalendar.class);
		MixedParamUrlCodingStrategy.put(URLConstants.GROUPS_FOLDER, in.muton.edushare.pages.group.GroupFolder.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_PEOPLE, in.muton.edushare.pages.group.GroupPeople.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_POLL, in.muton.edushare.pages.group.GroupPoll.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_INVITE, in.muton.edushare.pages.group.InvitePeople.class);
		
		//Public Pages for user
		IndexedParamUrlCodingStrategy.put(URLConstants.USER_PUBLIC_PAGE_SUMMARY, in.muton.edushare.pages.publicpages.userpages.UserProfile.class);
		IndexedParamUrlCodingStrategy.put(URLConstants.USER_PUBLIC_PAGE_PORTFOLIO, in.muton.edushare.pages.publicpages.userpages.ProfessionalProfile.class);
		IndexedParamUrlCodingStrategy.put(URLConstants.USER_PUBLIC_PAGE_PUBLICATIONS, in.muton.edushare.pages.publicpages.userpages.UserPublications.class);
		IndexedParamUrlCodingStrategy.put(URLConstants.USER_PUBLIC_PAGE_COURSES, in.muton.edushare.pages.publicpages.userpages.UserCoursesPublic.class);
		IndexedParamUrlCodingStrategy.put(URLConstants.USER_PUBLIC_PAGE_DEPTS, in.muton.edushare.pages.publicpages.userpages.UserDeptsPublic.class);
		
		//Public Pages for university
		IndexedParamUrlCodingStrategy.put(URLConstants.UNIV_PUBLIC_PAGE_HOME, in.muton.edushare.pages.publicpages.univpages.UnivPublic.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIV_PUBLIC_PAGE_DEPT, in.muton.edushare.pages.publicpages.univpages.UnivPublicDept.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIV_PUBLIC_PAGE_COURSES, in.muton.edushare.pages.publicpages.univpages.UnivPublicCourse.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.UNIV_PUBLIC_PAGE_PEOPLE, in.muton.edushare.pages.publicpages.univpages.UnivPublicUsers.class);
		
		//Public pages for department
		IndexedParamUrlCodingStrategy.put(URLConstants.DEPT_PUBLIC_PAGE_HOME, in.muton.edushare.pages.publicpages.deptpages.DeptPublic.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPT_PUBLIC_PAGE_COURSES, in.muton.edushare.pages.publicpages.deptpages.DeptCoursesPublic.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.DEPT_PUBLIC_PAGE_PEOPLE, in.muton.edushare.pages.publicpages.deptpages.DeptPeoplePublic.class);

		//Public pages for courses
		IndexedParamUrlCodingStrategy.put(URLConstants.COURSE_PUBLIC_PAGE_HOME, in.muton.edushare.pages.publicpages.coursepages.CoursePublic.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.COURSE_PUBLIC_PAGE_PEOPLE, in.muton.edushare.pages.publicpages.coursepages.CoursePeoplePublic.class);
		
		//Group public pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_PROFILE, in.muton.edushare.pages.publicpages.group.GroupHome.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.GROUPS_PUBLIC_MEMBERS, in.muton.edushare.pages.publicpages.group.GroupMembersPage.class);
		
		//Assignment Pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.ASSIGNMENT_PATH, in.muton.edushare.pages.assignment.Detail.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.ASSIGNMENT_SUBMISSION, in.muton.edushare.pages.assignment.Submissions.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.ASSIGNMENT_EDIT, in.muton.edushare.pages.assignment.Edit.class);

		//Poll Pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.POLL_RESULT, in.muton.edushare.poll.pages.PollResults.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.POLL_SUMMARY, in.muton.edushare.poll.pages.PollEdit.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.POLL_RESPONSE, in.muton.edushare.poll.pages.PollAnswer.class);
		
		//Batch Pages
//		IndexedHybridUrlCodingStrategy.put(URLConstants.BATCH_NEW, in.muton.edushare.pages.batch.NewBatch.class);	
		MixedParamUrlCodingStrategy.put(URLConstants.BATCH_PEOPLE, in.muton.edushare.pages.batch.BatchPeople.class);	
		MixedParamUrlCodingStrategy.put(URLConstants.BATCH_SUMMARY, in.muton.edushare.pages.batch.BatchSummary.class);	
		
		//Program Pages
		IndexedHybridUrlCodingStrategy.put(URLConstants.PROGRAM_NEW, in.muton.edushare.pages.curricula.NewCurriculaPage.class);
		IndexedHybridUrlCodingStrategy.put(URLConstants.PROGRAM_SUMMARY, in.muton.edushare.pages.curricula.CurriculaSummary.class);
		
		//ERROR PAGES
		HybridUrlCodingStrategy.put(URLConstants.PAGE_NOT_FOUND_PATH, in.muton.edushare.errorPages.PageNotFound.class);
		HybridUrlCodingStrategy.put(URLConstants.UNAUTHORIZED_PATH, in.muton.edushare.errorPages.NotAuthorizedPage.class);
		HybridUrlCodingStrategy.put(URLConstants.INTERNAL_ERROR_PATH, in.muton.edushare.errorPages.InternalErrorPage.class);
	}
	
	public static Class<? extends WebPage> getPageClass(String pageName){
		
		if(IndexedHybridUrlCodingStrategy.get(pageName)!=null)
			return IndexedHybridUrlCodingStrategy.get(pageName);
		else if(HybridUrlCodingStrategy.get(pageName)!=null)
			return HybridUrlCodingStrategy.get(pageName);
		else if(IndexedParamUrlCodingStrategy.get(pageName)!=null)
			return IndexedParamUrlCodingStrategy.get(pageName);
		else if(QueryStringUrlEncodingStrategy.get(pageName)!=null)
			return QueryStringUrlEncodingStrategy.get(pageName);
		else if(MixedParamUrlCodingStrategy.get(pageName)!=null)
			return MixedParamUrlCodingStrategy.get(pageName);
		else 
			return null;
	}
	
	public static Class<? extends WebPage> getLandingPageClass(int landingPageId){
			if(landingPageId == Users.LANDING_PAGE_USER_INVITATION)
				return in.muton.edushare.registration.InvitedUserLoginCreationPage.class;
			else if(landingPageId == Users.LANDING_PAGE_UNIVERSITY_SETUP)
				return in.muton.edushare.registration.university.UnivInvite.class;
			else
				return in.muton.edushare.pages.user.UserPage.class;
	}

}
